The present invention relates to image processing of image data represented by gradation. More particularly, the present invention relates to a graded color acquisition method and apparatus for acquiring gradation information of individual gradation levels in a color gradation or a density gradation (i.e. a so-called "grey scale" in the case of black and white representation).
A density gradation is, for example, a set of color data items and gradation information related to the set of color data items, and is hereinafter generally referred to as "graded color."
Recently, computer systems are becoming widely used in multimedia applications to produce various images, such as video created by television systems (TV), CG images created by computer graphic systems (CG), and medical images created by medical image systems. These images are often treated by image processing programs. Unlike character images and simple color coding images, the above images contain gradation components such as neutral colors or light, and shades for representing gradation by density or color. In such gradation, as the number of gradation levels of the gradation components increases, the number of graded colors become larger and the gradation distribution of graded colors become more uniform. In other words, as the number and distribution of graded colors increases, a gradation representation which is closer to a natural gradation representation can be obtained.
In the application of image processing, that is, during execution of an image processing program, the number of colors which can be treated by a system such as an operating system is smaller than the number of colors which can be represented by hardware. Furthermore, in many cases, the number of colors which can be actually treated by the image processing program is smaller than the number of colors which can be treated by the entire system. Moreover, graded color is generally obtained by mixing color information items in a complicated mixing ratio.
For this reason, and in order to make it possible to easily and stably treat graded color in an image processing program, the graded color is conventionally acquired by the program from the system at the start of the program.
Further, with the spread of multi-window systems and multi-task systems, an image processing program is often operated while another image processing program is being operated. In such a case, since the respective image processing programs individually acquire the graded colors, the number of remaining colors which can be later acquired from the system becomes small and in some cases a new image processing program can not acquire a necessary number of graded colors. In such a case, generally, error processing is effective to prevent the image processing program from being started.
For example, in a multi-task system, an image processing program (program &lt;A&gt;) may require the arrangement of uniform graded colors, as in the case of a grey scale representation using shades of black and white. If another program (program &lt;B&gt;) using a large number of colors is also being operated in the background, most colors which can be treated by the system are used by the program &lt;B&gt; and the remaining number of colors which can be treated becomes small. At this time, if the remaining number of colors is smaller than the number of colors necessary for successful operation of the program &lt;A&gt;, graded colors of a number required by the program &lt;A&gt; cannot be acquired, thereby making it impossible to start program &lt;A&gt;.
In a conventional image processing program, for example, as shown in FIG. 1, graded colors with a density gradation (i.e. a typical grey scale) having color numbers 1 to 9 may be obtained by mixing "black" and "white" according to a corresponding ratio. Then, the process of sequentially acquiring graded colors from the color 1 (i.e. "black") to the color 9 (i.e. "white") is effective.
Therefore, when the first half of the graded colors (for example, graded colors having colors 1 to 4) are acquired, it becomes impossible to acquire succeeding colors. Further, if an attempt is made to forcibly represent the image, the image as a whole becomes dark since no density gradation near the white portion is present. This make it impossible to correctly recognize the image. In such a case, the program recognizes the problem and is not started. That is, in the conventional image processing program, i.e. in a case where all necessary graded colors cannot be completely acquired, the program itself is not started.
The conventional graded color acquisition process is explained in detail with reference to FIG. 2. When a conventional graded color acquisition process is started, it is first determined whether a blank (i.e. a space) is present in the color table of the system (step S1). If a blank is present in the color table, the graded color acquisition process is sequentially effected from the color 1 as described above (step S2). Each time color acquisition is effected, a determination is then made whether all necessary colors have been acquired (step S3). If all colors have not been acquired, the process returns to step S1.
Thus, color acquisition is effected if a blank is present in the color table and continues until step S3 determines that all necessary colors have been acquired. If it is determined in step S3 that the acquisition of all colors is completed, the process is terminated.
Since it becomes impossible to ensure that a required number of colors for obtaining an adequate color distribution can be acquired if it is determined in step S1 that a blank is present in the color table, an error process is effected, starting of the program is interrupted (step S4), and the process is ended.
Further, in a case where colors are already acquired and used in program &lt;B&gt;, colors are selected which are "approximately" equal to the graded colors to be used in program &lt;A&gt; from the acquired colors. Then, the selected colors are used. However, with this method, the image represented in program &lt;A&gt; cannot be correctly recognized if a distribution of colors acquired by program &lt;B&gt; is non-uniform.
By way of example, an attempt may be made to acquire color 4 and succeeding color numbers by approximation to colors already acquired in program B, as shown in FIG. 3. However, in a state in which colors of color number 1 to color number 3 are acquired by use of the above color acquisition method, the color number of an acquired color which is nearest to color 4 is 2.5, as shown in FIG. 4. Thus, an inversion of colors used for actual representation occurs between the intended color 3 and the intended color 4 because the color 2.5 was substituted for color 4. Further, the entire color interval becomes non-uniform due to the acquisition of colors 4 to 9 by approximation.
The inversion of the array (i.e. order) of colors and the non-uniformity of the color interval will not develop into a serious problem when displaying characters or the like. However, in a case of a video image such as a TV image photographed by a camera, the non-uniformity of the color interval makes the gradation appear unnatural. For example, the non-uniformity may cause a display of solarization, an irregular concentration of colors, and a degradation of image quality. Therefore, correct recognition of an intended image cannot be expected. In practice, since color of a more irregular distribution may be approximated in some cases, the original image itself cannot even be recognized.
Therefore, even if colors are acquired by approximation, display of a proper image cannot be obtained. Further, in a case where a sufficiently large blank is not present in the color table and all required colors cannot be acquired, it is a common practice to not start the program. As described above, in the conventional image processing program, the process of sequentially acquiring graded colors of a necessary density gradation in an order of color numbers is first effected. For this reason, if an acquisition of remaining colors becomes impossible before all necessary graded colors are acquired, an adequate representation becomes impossible. Further, when colors acquired and used by program &lt;B&gt; are present, and if colors approximately equal to the graded colors required by program &lt;A&gt; are selected from the acquired colors and used as approximate colors, the inversion of the array of colors and the non-uniformity of colors intervals make the gradation appear unnatural. Moreover, image quality is degraded and it is often impossible to correctly recognize an original image. This effect is often produced in a video image, such as a TV image photographed by a camera. Therefore, a proper image cannot be obtained even if the colors are acquired by approximation.
Thus, in most conventional programs, the program itself is not started in a case where a sufficiently large blank is not present in the color table and all of the required colors cannot be acquired.